﻿#pragma once

#include "../../Shared/Globals.h"
#include "Envir.h"
#include "../MessageQueue.h"
#include "../MirDatabase/DragonInfo.h"
#include "../MirObjects/MonsterObject.h"
#include "../../Shared/Data/ItemData.h"
#include <vector>
#include <stdexcept>

using namespace Server::MirDatabase;
using namespace Server::MirObjects;
using namespace Server::MirObjects::Monsters;

namespace Server::MirEnvir
{
    class Dragon
    {
    private:
        const int ProcessDelay = 2000;
    public:
        int DeLevelDelay = 60 * (60 * 1000);
    private:
        long long ProcessTime = 0;
    public:
        unsigned char MaxLevel = Globals::MaxDragonLevel;
    private:
        Rectangle *DropArea;
    public:
        long long DeLevelTime = 0;
        bool Loaded = false;

        virtual ~Dragon()
        {
            delete DropArea;
            delete Info;
            delete LinkedMonster;
        }

    private:
        static Server::MirEnvir::Envir *getEnvir();

    protected:
        static Server::MessageQueue *getMessageQueue();

    private:
        const std::vector<Point*> BodyLocations = std::vector<Point*>
        {
            new Point(-3, -1),
            new Point(-3, -0),
            new Point(-2, -3),
            new Point(-2, -2),
            new Point(-2, -1),
            new Point(-2, 0),
            new Point(-2, 1),
            new Point(-1, -2),
            new Point(-1, -1),
            new Point(-1, 0),
            new Point(-1, 1),
            new Point(-1, 2),
            new Point(0, -2),
            new Point(0, -1),
            new Point(0, 1),
            new Point(0, 2),
            new Point(0, 3),
            new Point(1, -2),
            new Point(1, 0),
            new Point(1, 1),
            new Point(1, 2),
            new Point(1, 3),
            new Point(2, 1),
            new Point(2, 2)
        };


    public:
        DragonInfo *Info;
        MonsterObject *LinkedMonster;

        Dragon(DragonInfo *info);
        bool Load();
        void GainExp(int ammount);
        void LevelUp();
        void LevelDown();
        void Drop(unsigned char level);
    protected:
        bool DropItem(UserItem *item);

        bool DropGold(unsigned int gold);

    public:
        void Process();
    };
}
